import React from 'react'
import { useNavigate } from 'react-router-dom'
import { Button, Input, Form } from 'react-vant'
import axios from '../../api/http'
function Index() {
    // 12306登录
    const [form] = Form.useForm()
let nav=useNavigate()
    const onFinish =async values => {
      console.log(values)
      const res=await axios.post('/xx/login',values)
      console.log(res);
    //   获取token
      localStorage.setItem('token',res.data.data.accessToken)
      alert('登录成功')
      nav('/home')
      
    }
  return (
    <div>
       <Form
      form={form}
      onFinish={onFinish}
      footer={
        <div style={{ margin: '16px 16px 0' }}>
          <Button round nativeType='submit' type='primary' block>
            提交
          </Button>
        </div>
      }
    >
      <Form.Item
        tooltip={{
          message:
            '',
        }}
        intro=''
        rules={[{ required: true, message: '请填写用户名' }]}
        name='username'
        label='用户名'
      >
        <Input placeholder='请输入用户名' />
      </Form.Item>
      <Form.Item
        rules={[{ required: true, message: '请填写密码' }]}
        name='password'
        label='密码'
      >
        <Input placeholder='请输入密码' />
      </Form.Item>
    </Form>
    </div>
  )
}

export default Index
